package com.newspublish.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newspublish.system.entity.system.Comment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface CommentMapper extends BaseMapper<Comment> {

    //根据父评论获取子评论内容
    List<Comment> selectByParentId(@Param("commentId") Integer commentId,@Param("auditStatus") String auditStatus);

    //查询所有父评论ID为当前评论ID的评论列表
    List<Comment> selectByParentIdCuster(@Param("commentId") Integer commentId);

    //根据父评论id删除子评论
    int deleteByParentId(@Param("parentId")Long parentId);

    //根据主键获取内容
    Comment selectByPrimaryKey(@Param("commentId")Long commentId);

    //点赞评论
    @Update("update comment set like_count=like_count+1")
    int like(Long id);

    //获取所有评论
    List<Comment> selectAllComments();

    //获取谋篇文章下的所以子评论
    List<Comment> selectCOmmentsByOne(@Param("newsId")Long newsId, @Param("auditStatus")String auditStatus);

}
